use axum::{http::Request, Json};
use serde_json::{json, Value};

use crate::{
    facade::{builder::Builder, test::TestFacade},
    provider::test::TestProvider, system::{error::ErrorCode, web_ret::WebRet},
};

pub(crate) async fn index<T>(request: Request<T>) -> Json<Value> {
    let ret = TestProvider::builder().echo(request.uri().path().to_string());
    match ret {
        Ok(_v) => {
            Json(json!(WebRet::success(Some(_v))))
        },
        Err(_e) => { 
            Json(json!(ErrorCode::BIZ_ERROR_COMMON.to_web_ret().append_msg(format!("{}",_e))))
        },
    }
}
